/*
db table 嵌套的 struct 定义
*/

#pragma once

#include "typedef.h"
#include <string>
#include <vector>
#include <array>
#include "ProtoMarco.h"



namespace proto
{
	struct Pos
	{
		uint16 x = 0;
		uint16 y = 0;
		uint16 z = 0;
	};
	REFLECTION_EXTEND(Pos, x, y, z);

	struct DbScene
	{
		uint32 cfgId = 0;
		uint64 id = 0;
		uint32 lastWorldSceneId = 0; //最近进入的世界场景
		Pos pos;
	};
	REFLECTION_EXTEND(DbScene, cfgId, id, lastWorldSceneId, pos);

	struct PlayerBrief //角色简要信息 
	{
		uint64 id = 0;
		std::string name;
		uint32 lv = 0;
	};
	REFLECTION_EXTEND(PlayerBrief
		, id
		, name
		, lv
	);

	struct DbMail //邮件
	{
		uint64 id = 0;
		int64 timestamp = 0; //创建时间戳
		std::string sender;
		uint32 cfgid = 0; 
		std::string title;
		std::string content;
		std::string attachment; //附件
		bool bRead = false; //true表示已读
		bool bGet = false; //true表示附件已经领取
	};
	REFLECTION_EXTEND(DbMail
		, id
		, timestamp
		, sender
		, cfgid
		, title
		, content
		, attachment
		, bRead
		, bGet
	);
	
	struct DbFriendBrief //好友简要信息 
	{
		uint64 id = 0;
		std::string name;
		uint32 lv = 0;
	};
	REFLECTION_EXTEND(DbFriendBrief
		, id
		, name
		, lv
	);

	struct DbSvrBase //服务器基本 信息
	{
		int64 startTimestamp = 0; //开服时间戳

	};
	REFLECTION_EXTEND(DbSvrBase
		, startTimestamp
	);

	struct DbBroadCastMail //系统广播邮件
	{
		uint64 sysMailIdSeed = 0; //系统广播邮件当前已用最大ID， 递增
		std::map<uint64, DbMail> id2SysMail; //所有系统广播邮件。 id从1开始，递增
	};
	REFLECTION_EXTEND(DbBroadCastMail
		, sysMailIdSeed
		, id2SysMail
	);


	struct DbUnionMem //工会成员信息， 需要存在工会数据里的 . (那种不需要会员查看的信息，别存这里，存player自己身上吧)
	{
		uint64 id = 0;
		uint32 score = 0; //比如贡献分数
		std::string name;	
		uint32 lv = 0;
		uint8 job = 0; //职位
		DbUnionMem(uint64 _id=0)
			:id(_id)
		{
		}
	};
	REFLECTION_EXTEND(DbUnionMem
		, id
		, score
		, name
		, lv
		, job
	);

}